<?php
//创建内存表
$swoole_table = new swoole_table(1024);

//内存表增加一列
$swoole_table->column('id', Swoole\Table::TYPE_INT,4);
$swoole_table->column('name', Swoole\Table::TYPE_STRING,64);
$swoole_table->column('age', Swoole\Table::TYPE_INT,2);
$swoole_table->create();
//存储
$swoole_table->set("fengqin",['id'=>1,'name'=>'fengqin','age'=>18]);
//另一种存储方式
$swoole_table['fQin_1'] = [
    'id'=>2,
    'name'=>'fqin_2',
    'age'=>'25'
];
//检查 table 中是否存在某一个 key。
//echo $swoole_table->exist('fengqin') ? 123 : 456;
//die();
//获取值
print_r($swoole_table->get("fQin_1"));
//另一种获取值的方式 对象格式
print_r($swoole_table['fengqin']);
//原子自增操作
$swoole_table->incr("fQin_1",'age',2);
print_r($swoole_table['fQin_1']);
//原子自减操作
$swoole_table->decr("fQin_1",'age',2);
print_r($swoole_table->get("fQin_1"));
//删除内存数据
echo "delete start:".PHP_EOL;
$swoole_table->del("fQin_1");
print_r($swoole_table['fQin_1']);

